<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>订单列表</title>
	<base href="${PATH}">
	<script type="text/javascript" src="/js/jquery3.2.js"></script>
<script type="text/javascript">
	function pay(id,stat,rowid,stat2){
		$.ajax(
				{
					url:"/servlet/updateStatus",
					type:"post",
					data:{"id":id,"stat":stat},
					dataType:"json",
					success:function(data){
						if(data.result==1){
							if(stat2==2){
								$("#"+rowid).html("<input type='button' value='正在配货'>");
							}
							if(stat2==6){
								$("#"+rowid).html("<input type='button' value='已取消'>");
							}
						}
					}
				}
		)
	}
</script>
</head>
<body>
<h3>用户名:${USER.account}</h3>
<h4>上次登录时间:${USER.logintime}</h4>
		<div>
			<table width="90%" style="margin: 0 auto;text-align: center;" border="1px slide #999" cellpadding="0" cellspacing="0">
				<thead>
					<tr>
						<td>编号</td>
						<td>商品编号</td>
						<td>商品价格</td>
						<td>日期</td>
						<td>收货人姓名</td>
						<td>收货人电话</td>
						<td>收货人地址</td>
						<td>商品来源</td>
						<td>商品状态</td>
					</tr>
				</thead>
				<tbody>
					<c:if test="${empty DTOQUERY}">
						<tr>
							<td colspan="9">没有商品</td>
						</tr>
						</c:if>
					<c:if test="${not empty DTOQUERY }">
						<c:forEach var="str" items="${DTOQUERY}" varStatus="status">
							<tr>
								<td>${status.count}</td>
								<td>${str.goodsEntity.orderNumber }</td>
								<td>${str.goodsEntity.amout }</td>
								<td>${str.goodsEntity.placeOrder }</td>
								<td>${str.goodsEntity.consignee }</td>
								<td>${str.goodsEntity.consigneePhone }</td>
								<td>${str.goodsEntity.consigneeAddress }</td>
								<td>${str.sourceEntity.sourceName }</td>
								<td id="${status.count}">
									<!-- 支付状态 -->
									<c:if test="${str.statusEntity.id==1 }">
										<input type="button" value="支付" onclick="pay(${str.goodsEntity.id},2,${status.count},2)">
										<input type="button" value="取消" onclick="pay(${str.goodsEntity.id},6,${status.count},6)">
									</c:if>
									<!-- 不是支付状态 -->
									<c:if test="${str.statusEntity.id!=1 }">
										<input type="button" value="${str.statusEntity.statusName }">
									</c:if>
								</td>
							</tr>						
						</c:forEach>
					</c:if>
				</tbody>
				
			</table>
		</div>
</div>
</body>
</html>